﻿

namespace DbWord.Request
{
    using System.Configuration;
    using System.Data;
    using System.Data.OracleClient;

    class Oracle:Idb
    {
        static string Connstr = ConfigurationManager.ConnectionStrings["OraConnection"].ConnectionString;

        public string ExecuteScalar(string sql)
        {
            object o = null;

            using (OracleConnection conn = new OracleConnection(Connstr))
            using (OracleCommand exec = new OracleCommand(sql, conn))
            {
                conn.Open();
                o = exec.ExecuteScalar();
                conn.Close();
            }
            if (o != null)
                return o.ToString();
            else return string.Empty;
        }

        public DataTable FillTable(string sql)
        {
            DataTable tb = new DataTable();

            using (OracleConnection conn = new OracleConnection(Connstr))
            using (OracleDataAdapter da = new OracleDataAdapter(sql, conn))
            {
                da.Fill(tb);
            }

            return tb;
        }
    }
}
